package com.cskaoyan.javase.oop1._7exercise._1pvz;

/**
 * 植物类
 * @since 17:06
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Plant {
    // 属性
    String name;
    int hp;
    double price;
    int damage;

    // 直接持有僵尸对象的引用作为成员变量,方便对象之间的交互
    Zombie plantZ;

    // 行为
    public void attack() {
        // 输了攻击了谁
        System.out.println(name + "正在攻击" + plantZ.name);
    }

    public void beAttacked() {
        System.out.println(name + "正在被" + plantZ.name + "攻击,还剩下" + (hp - plantZ.damage) + "点血量!");
    }

    // 构造方法

    public Plant() {
    }

    public Plant(String name, int hp, double price, int damage) {
        this.name = name;
        this.hp = hp;
        this.price = price;
        this.damage = damage;
    }
}
